﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Resources;
using Path = System.Windows.Shapes.Path;

namespace Sonce.Editor
{
	public partial class Editor
	{
		#region Ordering
		/// <summary>
		/// Move element to the top (render above other elements) in the containing layer.
		/// </summary>
		/// <param name="element">FrameworkElement</param>
		public void MoveToFront(FrameworkElement element)
		{
			int oldIndex = this.layoutManager.GetOrderIndex(element);
			int newIndex = this.layoutManager.MoveToFront(element);
			if (oldIndex >= 0 && newIndex >= 0 && oldIndex != newIndex)
			{
				//this.undoManager.Add(oldIndex, newIndex, element);
			}
		}

		/// <summary>
		/// Move element to the back (render below other elements) in the containing layer.
		/// </summary>
		/// <param name="element">FrameworkElement</param>
		public void MoveToBack(FrameworkElement element)
		{
			int oldIndex = this.layoutManager.GetOrderIndex(element);
			int newIndex = this.layoutManager.MoveToBack(element);
			if (oldIndex >= 0 && newIndex >= 0 && oldIndex != newIndex)
			{
				//this.undoManager.Add(oldIndex, newIndex, element);
			}
		}

		/// <summary>
		/// Move element one step higher in the containing layer.
		/// </summary>
		/// <param name="element">FrameworkElement</param>
		public void MoveForward(FrameworkElement element)
		{
			int oldIndex = this.layoutManager.GetOrderIndex(element);
			int newIndex = this.layoutManager.MoveForward(element);
			if (oldIndex >= 0 && newIndex >= 0 && oldIndex != newIndex)
			{
				//this.undoManager.Add(oldIndex, newIndex, element);
			}
		}

		/// <summary>
		/// Move element one step lower in the containing layer.
		/// </summary>
		/// <param name="element">FrameworkElement</param>
		public void MoveBackward(FrameworkElement element)
		{
			int oldIndex = this.layoutManager.GetOrderIndex(element);
			int newIndex = this.layoutManager.MoveBackward(element);
			if (oldIndex >= 0 && newIndex >= 0 && oldIndex != newIndex)
			{
				//this.undoManager.Add(oldIndex, newIndex, element);
			}
		}

		public void MoveBackward(List<FrameworkElement> elements)
		{
			foreach (FrameworkElement element in elements)
			{
				MoveBackward(element);
			}
		}

		public void MoveBackward()
		{
			foreach (FrameworkElement element in this.SelectedElements)
			{
				MoveBackward(element);
			}
		}

		public void MoveForward(List<FrameworkElement> elements)
		{
			foreach (FrameworkElement element in elements)
			{
				MoveForward(element);
			}
		}

		public void MoveForward()
		{
			foreach (FrameworkElement element in this.SelectedElements)
			{
				MoveForward(element);
			}
		}

		public void MoveToBack(List<FrameworkElement> elements)
		{
			foreach (FrameworkElement element in elements)
			{
				MoveToBack(element);
			}
		}

		public void MoveToBack()
		{
			foreach (FrameworkElement element in this.SelectedElements)
			{
				MoveToBack(element);
			}
		}

		public void MoveToFront(List<FrameworkElement> elements)
		{
			foreach (FrameworkElement element in elements)
			{
				MoveToFront(element);
			}
		}

		public void MoveToFront()
		{
			foreach (FrameworkElement element in this.SelectedElements)
			{
				MoveToFront(element);
			}
		}
		#endregion
	}
}
